package hello.controller.fuga;

import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;

import hello.service.BakaService;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

public class SetUserController extends Controller {

    @Override
    public Navigation run() throws Exception {
        Boolean isOk = BakaService.getInstance().verifyRequestParameter(this.request, Arrays.asList("user_id", "name", "profile_image_url"));
        if(!isOk){
            
        }
        String userId = this.request.getParameter("user_id");
//        String name = URIUtil.decode(this.request.getParameter("name"), "Windows-31J");
//        String name =  URLDecoder.decode(this.request.getParameter("name"));
        String name =  this.request.getParameter("name");
        String profileImageUrl =  this.request.getParameter("profile_image_url");
        
        
        try{
            BakaService.getInstance().setUser(userId, name, profileImageUrl);
        }
        catch(Exception ex){
            
        }
        this.response.getWriter().print("__SUCCESS__");
        return null;
    }
}
